\documentclass[twoside,a4paper]{article}
\usepackage{geometry}
\geometry{margin=1.5cm, vmargin={0pt,1cm}}
\setlength{\topmargin}{-1cm}
\setlength{\paperheight}{29.7cm}
\setlength{\textheight}{25.3cm}

% useful packages.
\usepackage{amsfonts}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{enumerate}
\usepackage{graphicx}
\usepackage{multicol}
\usepackage{fancyhdr}
\usepackage{layout}
\usepackage{multirow}

% some common command
\newcommand{\dif}{\mathrm{d}}
\newcommand{\avg}[1]{\left\langle #1 \right\rangle}
\newcommand{\difFrac}[2]{\frac{\dif #1}{\dif #2}}
\newcommand{\pdfFrac}[2]{\frac{\partial #1}{\partial #2}}
\newcommand{\OFL}{\mathrm{OFL}}
\newcommand{\UFL}{\mathrm{UFL}}
\newcommand{\fl}{\mathrm{fl}}
\newcommand{\op}{\odot}
\newcommand{\Eabs}{E_{\mathrm{abs}}}
\newcommand{\Erel}{E_{\mathrm{rel}}}

\begin{document}

\pagestyle{fancy}
\fancyhead{}
\lhead{NAME Jiatu Yan}
\chead{Numerical OPD/PDE Project02 - answer}
\rhead{Date 2021.6.9}


\section*{I. Function1 (Nonhomogeneous boundary condition in 1d)}

The Function1 is 
\[
	u\left( x \right)=\exp\left( \sin x \right)  
.\] 
We can derive the 1-dimension Poisson function with nonhomogeneous boundary condition about Function1, which is
\[
\left\{
	\begin{array}{l}
		-u''\left( x \right)=-\sin\left( x \right)  e^{\sin\left( x \right) }
		+ \cos^2\left( x \right)e^{\sin\left( x \right) }, \\
		u\left( 0 \right)=1,\quad u\left( 1 \right)=e^{\sin\left( 1 \right) }. \\ 
	\end{array}
\right.
\]

\subsection*{Problem II} 
Since the data is too large to put all of them in the document, I only list part of them. So do I in the following sections.

As an example, for V-cycles with fullweighting restriction operator and linear interpolation operator, we have

\begin{table}[ht]
	\caption{The convergence ratio for VC with full-weighting restriction operator and linear interpolation operator on function 1.}
	\label{tabular11}
	\centering
\begin{tabular}{|c|c|c|c|c|}
	\hline
	n&step&residual&convergence ratio&order\\
	\hline
	\multirow{4}{*}{128}&    1&      0.211588071656820809&   0.091210529134731752&   0.493522259193961810\\
	\cline{2-5}
	&2&      0.017839152572786343&   0.084310766826780500&   0.509734186976563808\\
	\cline{2-5}
	&3&      0.001530963713124223&   0.085820428233777779&   0.506076441398998877\\
	\cline{2-5}
	&4&      0.000135517647565475&   0.088517870413091365&   0.499698206709493609\\
	\hline
	\multirow{4}{*}{256}&1&      0.216754716091429156&   0.093437745296028302&   0.427481341019787742\\
	\cline{2-5}
	&2&      0.018473249552313220&   0.085226517260741083&   0.444069226417149687\\
	\cline{2-5}
	&3&      0.001638661123750662&   0.088704541077639962&   0.436856028380829764\\
	\cline{2-5}
	&4&      0.000145606198715509&   0.088856809138326887&   0.436546731862159920\\
	\hline
	\multirow{4}{*}{512}&1&      0.219333098952254613&   0.094549224138886931&   0.378087841128530833\\
	\cline{2-5}
	&2&      0.018846053446726074&   0.085924347655474312&   0.393421021799090331\\
	\cline{2-5}
	&3&      0.001692955552250464&   0.089830773166175160&   0.386294048743875240\\
	\cline{2-5}
	&4&      0.000150822243210946&   0.089088129343063191&   0.387624775432182045\\
	\hline
	\multirow{4}{*}{1024}&1&      0.220620766492135356&   0.095104306647756501&   0.339434551705185050\\
	\cline{2-5}
	&2&      0.019110246154119714&   0.086620341584213251&   0.352915032814182683\\
	\cline{2-5}
	&3&      0.001720157794826260&   0.090012330608072011&   0.347373354290351988\\
	\cline{2-5}
	&4&      0.000153453482163002&   0.089208956657665789&   0.348666762450695444\\
	\hline
\end{tabular}
\end{table}

As shown in Table \ref{tabular11}, we have the reduction rate of VC with fullweighting operator and linear interpolation operator is about 0.09.

\subsection*{Problem III} 

For VCs with different restriction operator and interpolation operator, we can get the minimal residual the solver can get, which is
\begin{table}[ht]
	\caption{The minimal residual of each VCs}
	\label{tabular12}
	\centering
	\begin{tabular}{|c|c|c|c|c|}
		\hline
		Restriction operator&Interpolation operator&n&step&residual\\
		\hline
		Fullweighting& Linear&512&    7&      0.000000180463306299\\
		\hline
		Fullweighting& Quadratic&512&    4&      0.000000195939943159\\
		\hline
		Injection&Linear&512&    10&     0.000000208710205785\\
		\hline
		Injection&Quadratic&512&    9&      0.000000199051106042\\
		\hline
		Injection&Quadratic&1024&   10&     0.000000043916483783\\
		\hline
	\end{tabular}
\end{table}

As shown in Table \ref{tabular12}, for $N=512$, we achived minimal error $e\approx2\times10^{-7}$. This error may be induced
by the high Fourier modes that cannot be represented in the grid. 
Since if we let $N=1024$, the minimal error becomes $e\approx 4\times 10^{-8}$.The minimal error is the same as that of FMG method.

\section*{II. Function2 (Homogeneous boundary condition in 1d)}

The Function2 is
\[
	u\left( x \right)=x^2-x 
.\]
We can deduce the 1-dimensional Poisson function with homogeneous boundary condition about it, which is
\[
	\left\{
		\begin{array}{l}
			-u''\left( x \right)=-2,\\
			u\left( 0 \right)=u\left( 1 \right)=0.\\  
		\end{array}
		\right.
	\] 

\subsection*{Problem II}
Like Function1, I only list part of the solution.

\begin{table}[ht]
        \caption{The convergence ratio for VC with injection restriction operator and quadratic interpolation operator on function 2.}
        \label{tabular21}
        \centering
\begin{tabular}{|c|c|c|c|c|}
        \hline
        n&step&residual&convergence ratio&order\\
        \hline
	\multirow{3}{*}{128}
	 &    1&      0.009371849565188217&   0.037487398260752869&   0.676778641155716842\\
	\cline{2-5}
	 &    2&      0.000376141307511346&   0.040135226765538899&   0.662712448695134682\\
	\cline{2-5}
	 &    3&      0.000020102569492794&   0.053444195283411725&   0.603688989753740413\\
        \hline
	\multirow{3}{*}{256}
	 &    1&      0.009384189201154580&   0.037536756804618321&   0.591944022978244444\\
	\cline{2-5}
	 &    2&      0.000376978170543496&   0.040171629371785755&   0.579709901389588445\\
	\cline{2-5}
	 &    3&      0.000020203800420115&   0.053594085808701654&   0.527722797995648363\\
        \hline
	\multirow{3}{*}{512}
	 &    1&      0.009387495784470234&   0.037549983137880938&   0.526115992209859273\\
	\cline{2-5}
	 &    2&      0.000377172937238462&   0.040178227069078518&   0.515271365067884513\\
	\cline{2-5}
	 &    3&      0.000020222571380749&   0.053616178108672523&   0.469020867288193810\\
        \hline
	\multirow{3}{*}{1024}
	 &   1&      0.009388371744679047&   0.037553486978716188&   0.473490931630049516\\
	\cline{2-5}
	 &   2&      0.000377201618767892&   0.040177533338693630&   0.463746719586956402\\
	\cline{2-5}
	 &   3&      0.000020224801735011&   0.053618014156657533&   0.422113840237137439\\
        \hline
\end{tabular}
\end{table}

From Table \ref{tabular21} we can see the convergence ratio of the VC on Function2 is about 0.04.

\section*{III. Function3 (Nonhomogeneous boundary condition in 2d)}

The Function3 is
\[
	u\left( x, y \right)=e^{\sin\left( x \right)\sin\left( y \right)  } 
.\] 
We deduce the 2-dimensional Poisson function 
\[
\left\{
	\begin{array}{l}
		-u''\left( x, y \right)=\left[\sin\left( x \right)+\sin\left( y \right)
		-\cos^2\left( x \right)-\cos^2\left( y \right)  \right]e^{\sin\left( x \right)\sin\left( y \right)  } 
			\quad \left( x, y \right) \in \Omega,\\
			u\left( x, y \right)=e^{\sin\left( x \right)\sin\left( y \right)  }  
			\quad \left( x, y \right) \in\partial\Omega.\\
	\end{array}
	\right.
\] 
\subsection*{Problem II}

\begin{table}[ht]
        \caption{The convergence ratio for VC with full-weighting restriction operator and linear interpolation operator on function 3.}
        \label{tabular31}
        \centering
\begin{tabular}{|c|c|c|c|c|}
        \hline
        n&step&residual&convergence ratio&order\\
        \hline
        \multirow{3}{*}{128}
	 &    1&      0.561433539844271357&   0.276557840483390716&   0.264906693070200483\\
	\cline{2-5}
	 &    2&      0.167589016256747492&   0.298501967487073916&   0.249169664895716042\\
	\cline{2-5}
	 &    3&      0.033857775634171361&   0.202028607783585418&   0.329624071146139508\\
        \hline
        \multirow{3}{*}{256}
        &    1&      0.561218585250115698&   0.276451955504773028&   0.231862414768000791\\
	\cline{2-5}
	&    2&      0.167358276856240495&   0.298205157945107435&   0.218202860410484173\\
	\cline{2-5}
	&    3&      0.033906000316316076&   0.202595300054631167&   0.287915923624218695\\
        \hline
	\multirow{3}{*}{512}
        &    1&      0.561157411192971800&   0.276421821635068621&   0.206117398182236899\\
	\cline{2-5}
	&    2&      0.167301760347148276&   0.298136952324089044&   0.193994766099942595\\
	\cline{2-5}
	&    3&      0.033918819539436207&   0.202740362498608745&   0.255810528779896129\\
        \hline
        \multirow{3}{*}{1024}
	&   1&      0.561142255476114959&   0.276414356045595555&   0.185509554841612023\\
	\cline{2-5}
	&   2&      0.167287561733293400&   0.298119701556522676&   0.174603637437653225\\
	\cline{2-5}
	&3&      0.033921700409073718&   0.202774791249304559&   0.230204978574221897\\
        \hline
\end{tabular}
\end{table}

As we can see from Table \ref{tabular31}, the convergence rate is about $0.2$.

\subsection*{Problem III}
\begin{table}[ht]
        \caption{The minimal residual of each VCs}
        \label{tabular2}
        \centering
        \begin{tabular}{|c|c|c|c|c|}
                \hline
		Restriction operator&Interpolation operator&n&step&residual\\
                \hline
		Fullweighting&Linear&512&    3&      0.033918819539436207\\
                \hline
		Fullweighting& Quadratic&512&    5&      0.045625025559532739\\
                \hline
		Injection&Linear&512&    3&      0.029131871485241323\\
                \hline
		Injection&Quadratic&512&    5&      0.031024293327489572\\
                \hline
	\end{tabular}
\end{table}

We can see the minimal residual is too large.
Even I use FMG method to solve the equation, the error converges to 0.06.
I do't get a good solution. 
There may exist some bugs in the program for solving the nonhomogeneous boundary condition.
Or the error is introduced when I operate on the boundary condition.

\section*{IV. Function4 (Homogeneous boundary condition in 2d)}

Function4 is
\[
	u\left( x,y \right)=\left( x^2-x \right)\left( y^2-y \right)   
.\] 
The coordinate function is
\[
	\left\{
		\begin{array}{l}
			-u''=-2\left( y^2-y \right)-2\left( x^2-x \right) \quad\in\left( x, y \right)\in\Omega ,\\  
	u\left( x, y \right)=0\quad\left( x, y \right) \in\partial\Omega.\\ 
\end{array}
\right.
\]

\subsection*{Problem II}

For VC with fullweighting restriction operator and quadratic interpolation operator, we have
\begin{table}[ht]
        \caption{The convergence ratio for VC with full-weighting restriction operator and quadratic interpolation operator on function 4.}
        \label{tabular41}
        \centering
\begin{tabular}{|c|c|c|c|c|}
        \hline
        n&step&residual&convergence ratio&order\\
        \hline
        \multirow{3}{*}{128}
   &    2&      0.236274472951624182&   0.369055941950629074&   0.205441225221226820\\
	\cline{2-5}
   &    3&      0.096034659217870910&   0.406453807803153766&   0.185548098717834620\\
	\cline{2-5}
   &    4&      0.038214146498699364&   0.397920363438829860&   0.189921194934296433\\
	\hline
        \multirow{3}{*}{256}
   &    2&      0.236093597851043779&   0.368864597120841631&   0.179854595770857384\\
	\cline{2-5}
   &    3&      0.095919985653595052&   0.406279486299806036&   0.162431946557047596\\
	\cline{2-5}
   &    4&      0.038150412628610963&   0.397731634014074686&   0.166266597734519017\\
	\hline
        \multirow{3}{*}{512}
   &    2&      0.236048386200076621&   0.368821335408105744&   0.159889553371394488\\
	\cline{2-5}
   &    3&      0.095889841326477709&   0.406229599236491545&   0.144403636875090391\\
	\cline{2-5}
   &4&      0.038134643230354870&   0.397692213302525188&   0.147808420001729973\\
	\cline{2-5}
        
	\hline
        \multirow{3}{*}{1024}
   &   2&      0.236037256601005829&   0.368808768961436106&   0.143905513655292250\\
	\cline{2-5}
   &   3&      0.095882670251265845&   0.406218372607781208&   0.129967260298665066\\
	\cline{2-5}
   &   4&      0.038130668211022511&   0.397680499626251405&   0.133031827396186020\\
	\hline
\end{tabular}
\end{table}

From Table \ref{tabular41}, the reduction ratio of this VC is about 0.4.
\end{document}

%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 
